package com.sunchen.asc.application.rest;

import com.sunchen.asc.service.common.ResultResponse;
import com.sunchen.asc.service.parameter.api.ParamTypeService;
import com.sunchen.asc.service.parameter.vo.ParamTypeVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/param/type")
public class ParamTypeRest {

    @DubboReference
    private ParamTypeService paramTypeService;

    @ApiOperation(value = "创建参数类型")
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public ResultResponse create(@RequestBody @ApiParam(name="参数类型vo",value="传入json格式",required=true)ParamTypeVo paramTypeVo){

        return paramTypeService.create(paramTypeVo);
    }

    @ApiOperation(value = "编辑参数类型")
    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    public ResultResponse edit(@RequestBody @ApiParam(name="参数类型vo",value="传入json格式",required=true)ParamTypeVo paramTypeVo){

        return paramTypeService.edit(paramTypeVo);
    }

    @ApiOperation(value = "参数类型查询")
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiImplicitParam(name="name",value = "名称",required = false)
    public ResultResponse list(@RequestParam(required = false,defaultValue = "") String name){

        return paramTypeService.list(name);
    }

    @ApiOperation(value = "修改参数类型状态")
    @RequestMapping(value = "/status",method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "参数类型id"),
            @ApiImplicitParam(name="status",value = "状态值（1启用，0禁用）")
    })

    public ResultResponse status(@RequestParam Long id,@RequestParam int status){

        return paramTypeService.status(id,status);
    }
}
